<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>超全局变量是在全部作用域中始终可用的内置变量</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reserved.variables.globals.html">$GLOBALS</a></div>
 <div class="up"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="language.variables.superglobals" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">超全局变量</h1>
  <p class="refpurpose"><span class="refname">超全局变量</span> &mdash; <span class="dc-title">超全局变量是在全部作用域中始终可用的内置变量</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-language.variables.superglobals-description">
  <h3 class="title">说明</h3>
  <p class="para">
   PHP 中的许多预定义变量都是“超全局的”，这意味着它们在一个脚本的全部作用域中都可用。在函数或方法中无需执行 <strong class="command">global $variable;</strong> 就可以访问它们。
  </p>
  <p class="para">
   这些超全局变量是：
   <ul class="simplelist">
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.globals.html" class="classname">$GLOBALS</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.get.html" class="classname">$_GET</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.post.html" class="classname">$_POST</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.files.html" class="classname">$_FILES</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.cookies.html" class="classname">$_COOKIE</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.request.html" class="classname">$_REQUEST</a></var></var></li>
    <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.environment.html" class="classname">$_ENV</a></var></var></li>
   </ul>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-language.variables.superglobals-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.1.0</td>
       <td>
        超全局变量被引入到 PHP.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-language.variables.superglobals-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>变量可用性</strong><br />
   <p class="para">
    默认情况下，所有的超全局变量都是可用的。但是，有一些指令会影响这种可用性。更多信息，参见文档
    <a href="ini.core.html#ini.variables-order" class="link">variables_order</a>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>处理 register_globals</strong><br />
   <p class="para">
    如果已经弃用的 <a href="ini.core.html#ini.register-globals" class="link">register_globals</a> 指令被设置为 <em>on</em> 那么局部变量也将在脚本的全局作用域中可用。例如，
    <var class="varname"><var class="varname"><a href="reserved.variables.post.html" class="classname">$_POST['foo']</a></var></var> 也将以 <var class="varname"><var class="varname">$foo</var></var> 的形式存在。
   </p>
   <p class="para">
    相关信息，参见 FAQ “<a href="faq.using.html#faq.register-globals" class="link">register_globals 对我有什么影响？</a>”
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>可变变量</strong><br />
   <p class="para">
    在函数或类方法中，超全局变量不能被用作<a href="language.variables.variable.html" class="link">可变变量</a>。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-language.variables.superglobals-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="language.variables.scope.html" class="link">变量作用域</a></li>
    <li class="member"><a href="ini.core.html#ini.variables-order" class="link">variables_order</a> 指令</li>
    <li class="member"><a href="book.filter.html" class="link">过滤器扩展</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reserved.variables.globals.html">$GLOBALS</a></div>
 <div class="up"><a href="reserved.variables.html">预定义变量</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
